import request from '@/utils/request'

/**
 * 获取产品采购分页信息
 *
 * @param queryData
 * @returns {AxiosPromise}
 */
export function queryProductWithSpecification(queryData) {
  return request({
    url: '/purchase/get/ro',
    method: 'POST',
    data: {
      ...queryData
    }
  })
}

/**
 * 获取5个产品近四周销量
 *
 * @returns {AxiosPromise}
 */
export function getItemSaleWeeklyQuantity() {
  return request({
    url: '/purchase/get/dashboard',
    method: 'get',
  })
}

/**
 * 单个采购
 *
 * @param productData
 * @returns {AxiosPromise}
 */
export function purchaseOne(productData) {
  return request({
    url: '/purchase/purchase/one',
    method: 'POST',
    data: {
      ...productData
    }
  })
}

/**
 * 批量采购
 *
 * @param productListData
 * @returns {AxiosPromise}
 */
export function purchaseBatch(productListData) {
  return request({
    url: '/purchase/purchase/batch',
    method: 'POST',
    data: [
      ...productListData
    ]
  })
}

// 分页展示采购订单
export function queryPurchaseOrder(data) {
  return request({
    url: '/purchase/query/ro',
    method: 'POST',
    data: data
  })
}

// 查看采购订单详情
export function getPurchaseOrderDetail(id) {
  return request({
    url: '/purchase/get/item/list?purchaseId=' + id,
    method: 'GET'
  })
}
